

package com.hazelcast.scheduledexecutor.impl.operations;

import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.scheduledexecutor.impl.ScheduledExecutorDataSerializerHook;
import com.hazelcast.spi.impl.operationservice.BackupOperation;

import java.io.IOException;

public class CancelTaskBackupOperation extends AbstractSchedulerOperation implements BackupOperation {

    private String taskName;

    public CancelTaskBackupOperation() {
    }

    public CancelTaskBackupOperation(String schedulerName, String taskName) {
        super(schedulerName);
        this.taskName = taskName;
    }

    @Override
    public void run() throws Exception {
        getContainer().cancel(taskName);
    }

    @Override
    public int getClassId() {
        return ScheduledExecutorDataSerializerHook.CANCEL_BACKUP_OP;
    }

    @Override
    protected void writeInternal(ObjectDataOutput out) throws IOException {
        super.writeInternal(out);
        out.writeString(taskName);
    }

    @Override
    protected void readInternal(ObjectDataInput in) throws IOException {
        super.readInternal(in);
        this.taskName = in.readString();
    }
}
